﻿using SuperX.Common;
using System.Collections.Generic;

namespace SuperX.DataService
{
    public class TreeModel
    {
        /// <summary>
        /// 设备名
        /// </summary>
        public string Name { set; get; }

        /// <summary>
        /// 节点全称
        /// </summary>
        public string Key { set; get; }

        /// <summary>
        /// 父节点
        /// </summary>
        public string Parentkey { set; get; }

        /// <summary>
        /// 父节点配置全称
        /// </summary>
        public string ConfigParentkey { get; set; }

        /// <summary>
        /// 节点类型
        /// </summary>
        public int Type { set; get; }

        /// <summary>
        /// 配置设备全称
        /// </summary>
        public string ConfigKey { get; set; }

        /// <summary>
        /// 连接状态
        /// </summary>
        public bool ConectState { get; set; }

        public List<TreeModel> Children { set; get; } = new List<TreeModel>();

        /// <summary>
        /// 系统类型
        /// </summary>
        public TagType SystemType { get; set; }

        /// <summary>
        /// 无参构造函数
        /// </summary>
        public TreeModel()
        {
            Children = new List<TreeModel>();
        }

        /// <summary>
        /// 有参构造函数
        /// </summary>
        /// <param name="id">子id</param>
        /// <param name="name">名称</param>
        /// <param name="parentId">父id</param>
        public TreeModel(string id, string name, string parentId)
        {
            this.Key = id;
            this.Name = name;
            this.Parentkey = parentId;
            Children = new List<TreeModel>();
        }

        /// <summary>
        /// 有参构造函数
        /// </summary>
        /// <param name="id">子id</param>
        /// <param name="name">名称</param>
        /// <param name="parent">父节点</param>
        public TreeModel(string id, string name, BaseTreeNode parent)
        {
            this.Key = id;
            this.Name = name;
            this.Parentkey = parent.Id;
            Children = new List<TreeModel>();
        }

        /// <summary>
        /// 是否由模板创建
        /// </summary>
        public bool CreatedByTemplate { set; get; }

        /// <summary>
        /// 是否由模板创建
        /// </summary>
        public bool TemplateSync { set; get; }

        public int AddressExtend { get; set; }
    }

    public enum DriverTree
    {
        Server,
        Driver,
        DriverGroup,
        Node,
        ChildNode,
    }
}